home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / MPW / MPW noweb 2.7 / src / c / match.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-30  |  677 b   |  21 lines  |  [TEXT/MPS ]

  1. #line 10 "match.nw"
  2. #include <string.h>
  3. #include "match.h"
  4. static int matches(char *line, char *search) {
  5.     return !strncmp(line,search,strlen(search));
  6. }
  7. int is_keyword(char *line, char *keyword) {
  8.     char low_at_sign = '@';
  9.     return *line==low_at_sign && matches(line+1,keyword) && 
  10.            (line[strlen(keyword)+1]==' ' || line[strlen(keyword)+1]=='\n');
  11. }
  12. int is_begin(char *line, char *type) {
  13.     return is_keyword(line,"begin") && matches(line+1+6,type);
  14. }
  15. int is_end(char *line, char *type) {
  16.     return is_keyword(line,"end") && matches (line+1+4,type);
  17. }
  18. int is_index(char *line, char *type) {
  19.     return is_keyword(line,"index") && matches(line+1+6,type);
  20. }
  21.